package com.fy.fyzf.presenter;

import com.fy.fyzf.api.SubscriberCallBack;
import com.fy.fyzf.base.BasePresenter;
import com.fy.fyzf.bean.AddSignOne;
import com.fy.fyzf.bean.AddSignThree;
import com.fy.fyzf.bean.AddSignTwo;
import com.fy.fyzf.bean.ModifySignBean;
import com.fy.fyzf.bean.PassengerNumberBean;
import com.fy.fyzf.bean.BaseData;
import com.fy.fyzf.bean.SignDetailBean;
import com.fy.fyzf.view.AddSignCallback;

import java.util.List;

public class AddSignPresenter extends BasePresenter<AddSignCallback> {

    public AddSignPresenter(AddSignCallback view) {
        super(view);
    }
    public void getPassengerNumber(){
        addSubscription(mApiService.listCustomerNumber(), new SubscriberCallBack<BaseData<List<PassengerNumberBean>>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<List<PassengerNumberBean>> response) {
                mView.getPassengerNumberListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    //保存第一步
    public void saveOneStep(AddSignOne addSignOne){
        addSubscription(mApiService.addSignOne(addSignOne), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.saveOneStepSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    //保存第2步
    public void saveTwoStep(AddSignTwo addSignTwo){
        addSubscription(mApiService.addSigntTwo(addSignTwo), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.saveTwoStepSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    //保存第3步
    public void saveThreeStep(AddSignThree addSignThree){
        addSubscription(mApiService.addSignThree(addSignThree), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.saveThreeStepSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getSingnContractdetail(Integer id) {
        addSubscription(mApiService.getSignDetail(id), new SubscriberCallBack<BaseData<SignDetailBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<SignDetailBean> response) {
                mView.getSingnContractdetail(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void exChangeSignContract(ModifySignBean modifySignBean) {
        addSubscription(mApiService.updateSignContract(modifySignBean), new SubscriberCallBack<BaseData>(mView,false) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.exChangeSignContractSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }
}
